#!/bin/bash
### BEGIN INIT INFO
# Required-Start:  /usr/sbin/sshd  
### END INIT INFO

workdir="/usr/sbin/sshd"

scriptpath="/sshd.sh"

filepath=$workdir$scriptpath

start(){
    echo $filepath

    ###输出到log文件中
    #nohup ./xxx.sh >/dev/null 2>log &
    nohup /usr/sbin/sshd -D >/dev/null 2>&1 &
    echo 'sshd service OK'
}


stop(){
    serverpid=`ps -aux|grep "sshd"|grep -v grep|awk '{print $2}'`
    kill -9 $serverpid
    echo 'sshd stop OK'
}

restart(){
    stop
    echo 'sshd stop OK'
    start
    echo 'sshd service OK'
}

case $1 in
    "start")
    start
    ;;
    "stop")
    stop
    ;;
    "restart")
    restart
    ;;
    *)
    start
esac
